package com.webrtc.demo.util

import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

object HttpUtil {
    private val instance by lazy {
        val logging = HttpLoggingInterceptor()
        logging.level = HttpLoggingInterceptor.Level.BODY
        val client = OkHttpClient.Builder()
            .addInterceptor(logging)
            .build()
        val retrofit = Retrofit.Builder()
            .client(client)
            .addConverterFactory(
                GsonConverterFactory.create())
            .baseUrl("http://user.bg.bcval.me/")
            .build()
        retrofit.create(ApiService::class.java)
    }

    fun create(): ApiService {
        return instance
    }
}